1 package uba.db.sql.language;
2
3 import org.apache.commons.lang.builder.EqualsBuilder;
4 import org.apache.commons.lang.builder.HashCodeBuilder;
5
6 public class NegatedSelectionCriteria extends SelectionCriteriaBehavior {
7 private SelectionCriteria criteriaNegated;
8
9 public NegatedSelectionCriteria(SelectionCriteria selectionCriteria) {
10 this.criteriaNegated = selectionCriteria;
11 }
12
13 /***
14 * @see uba.db.sql.language.Visitable#accept(uba.db.sql.language.Visitor)
15 */
16 public void accept(Visitor visitor) {
17 visitor.visitNegatedSelectionCriteria(this);
18 }
19
20 /***
21 * @see java.lang.Object#equals(java.lang.Object)
22 */
23 public boolean equals(Object obj) {
24 return EqualsBuilder.reflectionEquals(this, obj);
25 }
26
27 /***
28 * @see java.lang.Object#hashCode()
29 */
30 public int hashCode() {
31 return HashCodeBuilder.reflectionHashCode(this);
32 }
33
34 /***
35 * @see java.lang.Object#toString()
36 */
37 public String toString() {
38 return "NOT (" + criteriaNegated + ")";
39 }
40
41
42
43
44
45
46 public Object valueWith(EvaluationContext context) {
47 Boolean toNegate = (Boolean) criteriaNegated.valueWith(context);
48 return new Boolean(!(toNegate.booleanValue()));
49 }
50 }